#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>
#include<stdio.h>
#define MAX 100000

 struct L_R
{
	int right;
	int left;
	int minleft;
	int minright;
};
 struct L_R p1 = { 0, 0, 0, 0 };

int MaxSub4(int K, int arr[])	
{
	int MaxSum = 0;
	int SubSum = 0;
	int i = 0;
	for (i = 0; i < K; i++)
	{
		SubSum += arr[i];
		if (p1.left == i && arr[p1.left] == 0)
			p1.left = p1.minleft = p1.minright = p1.right = i;
		else if (SubSum > MaxSum)
		{
			MaxSum = SubSum;
			 p1.minright = p1.right = i;
		} 
		else if (SubSum < 0)
		{
			SubSum = 0;
			p1.left = i + 1;
			if (p1.minleft == 0)
				p1.minleft = p1.left;
			if (p1.minleft > p1.left)
				p1.minleft = p1.left;
		}
	}
	return MaxSum;
}

void text4(void)
{
	int K = 0;
	int arr[MAX] = { 0 };
	scanf("%d", &K);
	for (int i = 0; i < K; i++)
	{
		scanf("%d", &arr[i]);
	}
	if (MaxSub4(K, arr) == 0 && arr[p1.left] != arr[p1.right])
	{
		p1.minleft = 0;
		p1.minright = K - 1;
	}
	printf("%d %d %d", MaxSub4(K, arr), p1.minleft, p1.minright);
}

int main()
{
	text4();
	return 0;
}



